package com.woniuxy.user.client;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Map;

/**
 * Flowable服务OpenFeign客户端
 * 用于远程调用flowable-server的审批相关API
 */
@FeignClient(name = "flowable-server", url = "${flowable.gateway.url:http://localhost:9999}/flowable-server")
public interface FlowableFeignClient {

    /**
     * 查询用户待办任务
     *
     * @param userName 用户名
     * @return 待办任务列表
     */
    @PostMapping("/workflow/queryUserFlow")
    Map<String, Object> getPendingTasks(@RequestParam("userName") String userName);

    /**
     * 查询用户已办任务
     *
     * @param userName 用户名
     * @return 已办任务列表
     */
    @PostMapping("/workflow/queryCompletedTasks")
    Map<String, Object> getCompletedTasks(@RequestParam("userName") String userName);

    /**
     * 审批通过
     *
     * @param taskId 任务ID
     * @return 审批结果
     */
    @PostMapping("/workflow/acceptFlow")
    Map<String, Object> approveTask(@RequestParam("taskId") String taskId);

    /**
     * 审批拒绝
     *
     * @param taskId 任务ID
     * @param reason 拒绝原因
     * @return 审批结果
     */
    @PostMapping("/workflow/rejectFlow")
    Map<String, Object> rejectTask(@RequestParam("taskId") String taskId, 
                                   @RequestParam("reason") String reason);

    /**
     * 获取审批历史
     *
     * @param params 查询参数
     * @return 审批历史数据
     */
    @PostMapping("/workflow/approvalHistory")
    Map<String, Object> getApprovalHistory(@RequestBody Map<String, Object> params);

    /**
     * 获取审批统计
     *
     * @param userName 用户名
     * @return 审批统计数据
     */
    @PostMapping("/workflow/approvalStatistics")
    Map<String, Object> getApprovalStatistics(@RequestParam("userName") String userName);
}
